/**
 * Debit card class extnds the abstract 
 * parent, Card.
 * @author Kristopher Gooding/Kyle Scharnhorst
 * @version 4/25/2014
 */
public class DebitCard extends Card {
	
	/**
	 * Constructor for the debit card class.
	 * @param the_name
	 * @param the_street
	 * @param the_town
	 * @param the_zip_code
	 * @param the_country
	 */
	public DebitCard(final String the_name, final String the_street,
			final String the_town, final String the_zip_code,
			final String the_country) {
		super(the_name, the_street, the_town, the_zip_code, the_country);
		my_card_number = my_last_card_number + 1;
		my_last_card_number++;
	}

	/**
	 * constructor for the debit card class that is 
	 * connected to a checking account.
	 * @param the_name
	 * @param the_street
	 * @param the_town
	 * @param the_zip_code
	 * @param the_country
	 * @param the_limit
	 * @param the_account
	 */
	public DebitCard(final String the_name, final String the_street,
			final String the_town, final String the_zip_code,
			final String the_country, final double the_limit,
			final CheckingAccount the_account) {
		super(the_name, the_street, the_town, the_zip_code, the_country,
				the_limit);
		my_last_card_number = my_last_card_number + 1;
		my_last_card_number++;
		my_account_connected_to = the_account;
	}

	/**
	 * method to pay towards the balance of the class.
	 * @param amount
	 * @return boolean representation of the success
	 *  of the transaction.
	 */
	public boolean pay(final double amount) {
		if ((my_account_connected_to.getBalance() - amount) < -my_account_connected_to
				.getDebitAmount()) {
			my_account_connected_to.setBalance(my_account_connected_to
					.getBalance() - amount);
			return true;
		} else {
			return false;
		}
	}

	/**
	 * @return my_account_connected_to
	 */
	public CheckingAccount getAccountConnectedTo() {
		return my_account_connected_to;
	}
}
